Q: When are the keyboard events fired?
Solution: The keydown and keyup are the keyboard events are fired when the user presses or releases a key on the keyboard. They are generated for modifier keys, function keys, and alphanumeric keys.
Q: How does a user generate multiple keydown events?
Solution: If the user holds the key down long enough for it to begin repeating, there will be multiple keydown events before the keyup event arrives. Pressing the key for long time results in multiple calls to the function onkeypress.
Q: Which property is used to specify the key type when pressed?
Solution: The keyCode property returns the Unicode character code of the key that triggered the onkeypress event, or the Unicode key code of the key that triggered the onkeydown or onkeyup event. The event object associated with these events has a numeric keyCode property that specifies which key was pressed.
Q: For what value does the keyCode property persists even when a Shift key is pressed for adding punctuation character.
Solution: The number keys always generate keyCode values for the digit that appears on the key, even if you are holding down Shift in order to type a punctuation character.
Q: Which of the following are not key event properties?
Solution: altKey, ctrlKeY, shiftKey, and metaKey are key event object’s properties, which are set to true if the corresponding modifier key is held down when the event occurs. The keyCode values of ShiftKey, ctrlKey, altKey are respectively 16, 17 and 18.
Q: Which of the following key property holds the key name as a string?
Solution: The DOM Level 3 Events defines a new key property that contains the key name as a string. Object.keys() returns an array whose elements are strings corresponding to the enumerable properties found directly upon object.
Q: Which of the following is not the value the key property will hold if the key is a function key?
Solution: If the key is a function key, the key property will be a value like “F2”, ”F8” or ”F9”etc. The Keys from F1-F12 are known as function keys.
Q: Which method is used to add a binding?
Solution: The bind() method creates a new function that, when called, has its this keyword set to the provided value, with a given sequence of arguments preceding any provided when the new function is called.
Q: Which method is used to remove a binding?
Solution: The unbind() method removes event handlers from selected elements. This method can remove all or selected event handlers, or stop specified functions from running when the event occurs.
Q: Which of the following are the parameters passed to the keymap after installation?
Solution: After the keymap is installed, the following parameters are passed: The event object for the keydown event. The key identifier of the key that was pressed. Identifier key contains the information of the key that is pressed and the object information about the function to be performed when the key is pressed.
You Have Score    | /10 |